import { _decorator, Collider2D, Component, director, Director, find, instantiate, Node, RigidBody2D } from 'cc';
import { EnemyState } from './EnemyState';
import { Enemy } from './Enemy';
import { EnemyStateMachine } from './EnemyStateMachine';
import { EnemyManager } from '../EnemyManager';
const { ccclass, property } = _decorator;

@ccclass('EnemyDeathState')
export class EnemyDeathState extends EnemyState {
    constructor(_enemy: Enemy, _stateMachine: EnemyStateMachine) {
        super(_enemy, _stateMachine);
    }

    override enter(): void {
        super.enter();
        this.enemy.SetVelocity(0, 0);
        setTimeout(() => {
            if (this.enemy.node && this.enemy.node.isValid) {
                this.enemy.node.destroy();
            }
        }, 50);
     


        this.enemy.playAnimation("siwang", false);
        this.enemy.spanSunExp()

    }

    override update(dt: number): void {
        super.update(dt);
    }

    override exit(): void {
        super.exit();
    }
}


